package com.zdkj.subway.stm.sequence;/**
 * @author 陈博
 * @date 2020/5/28 0028 13:54
 */

import com.zdkj.common.sequence.properties.SequenceDbProperties;
import com.zdkj.common.sequence.sequence.Sequence;
import com.zdkj.subway.stm.sequence.build.CycleDbSeqBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @program: zdkj
 *
 * @description:
 *
 * @author: chen
 *
 * @create: 2020-05-28 13:54
 **/
@Configuration
public class CycleSequence {
    @Bean
    public Sequence invoiceSequence(DataSource dataSource,
                             SequenceDbProperties properties) {
        return CycleDbSeqBuilder
                .create()
                .bizName(new CycleBizName())// 定义切片规则
                .dataSource(dataSource) // 注入数据源
                .step(10)     // 每次获取数据的个数
                .retryTimes(3)   // 重试次数
                .tableName("invoice_sequence") // 存储表名信息
                .build();
    }
}
